<template>
	<view>
		<header-top :messageInfo="{typeFlag:true,message:'设置大客户',liner:false}">
			<view class="rightmsg" slot="rightmsg">
				<view class="rightmsg_content">
					<view class="add" @click="jumpurl('/pages/workbench/xiaoshou/xuanzekuhu')"></view>
				</view>
			</view>
		</header-top>
		<view class="mainpadding2">

			<uni-swipe-action-item :right-options="options" @click="onClick" @change="swipeChange($event,item.id)"
			 :auto-close="false" v-for="item in list" :key="item.id">
				<view class="flexbetween itemlist">
					<view>
						<view class="strongtext">{{item.customer_name}}</view>
						<view class="margin_top smalltext xiankuan">{{item.getgoods_address}}</view>
						<view class="flexleft margin_top">
							<view class="scxse">上次销售额：</view>
							<view class="price">￥{{item.sales_money}}</view>
						</view>
					</view>
					<view class="flexright">
						<view class="flexcolumn right-mar">
							<view class="yuanquan weibaifang">{{item.visit}}天</view>
							<view class="margin_top weibaifang">未拜访</view>
						</view>
						<view class="flexcolumn right-mar">
							<view class="yuanquan weibaifang">{{item.order}}天</view>
							<view class="margin_top weibaifang">未下单</view>
						</view>
						<view class="flexcolumn right-mar">
							<view class="yuanquan weibaifang">{{item.push}}天</view>
							<view class="margin_top weibaifang">未推单</view>
						</view>
					</view>
				</view>
			</uni-swipe-action-item>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {                
			return {
				page: 1,
				limit: 12,
				list: [],
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#ff0000'
					}
				}],
				currentid:""
			}
		},
		onShow() {
			this.init()
			this.init1()
			this.init2()
		},
		methods: {
			// 点击删除按钮
			onClick(e) {
				console.log(e,888)
				httpRequest.request('appapi/manage/customer/major_del', 'POST', {
					id:this.currentid
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg);
					if (res.code == 1) {
						this.list.data.forEach((item,index)=>{
							if(item.id==this.currentid){
								this.list.data.splice(index,1)
							}
						})
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			// 滑动触发
			swipeChange(e,id) {
				console.log(e,999)
				this.currentid = id
				//组件打开或关闭时触发	
				// left:左侧 ，right：右侧，none：关闭
			},
			init() {
				let _this = this;
				httpRequest.request('appapi/manage/customer/major', 'POST', {
					major: 1,
					type: 'all', //all=全部,district=片区,line=线路
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						_this.list = resList
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			init1() {
				httpRequest.request('appapi/manage/customer/major', 'POST', {
					major: 1,
					type: 'district', //all=全部,district=片区,line=线路
				}, false, false, true).then(res => {
					console.log(res.data, '片区')
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			init2() {
				httpRequest.request('appapi/manage/customer/major', 'POST', {
					major: 1,
					type: 'line', //all=全部,district=片区,line=线路
				}, false, false, true).then(res => {
					console.log(res.data, '线路')
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			jumpurl(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.paddingzy {
		padding: 0 30rpx;
	}

	.itemlist {
		background-color: #fff;
		padding: 30rpx 0;
		border-bottom: 1rpx solid rgba(238, 238, 238, 1.0);
	}

	.margin_top {
		margin-top: 20rpx;
	}

	.xiankuan {
		width: 300rpx;
	}

	.smalltext {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.scxse {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.price {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #F3AD3D;
	}

	.right-mar {
		margin-right: 10rpx;
	}

	.yuanquan {
		width: 82rpx;
		height: 82rpx;
		text-align: center;
		line-height: 82rpx;
		background-color: #EBECEE;
		border-radius: 50%;

	}

	.weibaifang {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}
</style>
